/**
 * @param {ListNode} list1
 * @param {ListNode} list2
 * @return {ListNode}
 */
var mergeTwoLists = function(list1, list2) {

  for (let i = 0; i < list2.length; i++) {
    const ele = list2[i];
    list1.push(ele)
  }
  let l = sort(list1)
  return l
};

function sort(l) {
  for (let j = 0; j < l.length; j++) {
    for (let i = 0; i < j - 1; i++) {
      const ele1 = l[i];
      const ele2 = l[i + 1];
      if (l[i] > l[i + 1]) {
        let temp = l[i];
        l[i] = l[i + 1];
        l[i + 1] = temp;
      }
    }

  }

  return l
};
let l1 = [1, 2, 4];
let l2 = [1, 3, 4];
console.log(mergeTwoLists(l1, l2));